package com.yiliao.control;

import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.yiliao.service.ChannelService;
import com.yiliao.util.MessageUtil;

/**
 * CPS联盟控制层
 * @author Administrator
 *
 */
@Controller
@RequestMapping("admin")
public class ChannelControl { 

	@Autowired
	private ChannelService channelService;
	
	/**
	 * 获取渠道公告列表
	 * @param page
	 * @return
	 */
	@RequestMapping(value = {"get-channel-bulletin-list"},method = RequestMethod.POST)
	@ResponseBody
	Map<String, Object> getChannelBulletinList(int page){
		
		return channelService.getChannelBulletinList(page);
	}
	
	/**
	 * 
	 * @param t_id
	 * @param t_title
	 * @param t_img
	 * @param t_content
	 * @return
	 */
	@RequestMapping(value = {"save-or-update-channel-bulletin"},method = RequestMethod.POST)
	@ResponseBody
	MessageUtil saveOrUpdateChannelBulletin(Integer t_id,String t_title,String  t_img,String t_content) {
		
		return channelService.saveOrUpdateChannelBulletin(t_id, t_title, t_img, t_content);
	}
	
	/**
	 * 删除公告
	 * @param t_id
	 * @return
	 */
	@RequestMapping(value = {"del-channel-bulletin"},method = RequestMethod.POST)
	@ResponseBody
	MessageUtil delChannelBulletin(int t_id) {
		return channelService.delChannelBulletin(t_id);
	}
	
	/**
	 * 获取落地页列表
	 * @param page
	 * @return
	 */
	@RequestMapping(value = {"get-flooring-page-list"},method = RequestMethod.POST)
	@ResponseBody
	Map<String, Object> getFlooringPageList(int page){
		
		
		return channelService.getFlooringPageList(page);
	}

	
	/**
	 * 新增或修改落地页列表
	 * @param t_id
	 * @param t_name
	 * @param t_jump_url
	 * @return
	 */
	@RequestMapping(value = {"save-or-update-flooring-page"},method = RequestMethod.POST)
	@ResponseBody
	MessageUtil saveOrUpdateFlooringPage(Integer t_id,String t_name,String t_jump_url) {
		
		return channelService.saveOrUpdateFlooringPage(t_id, t_name, t_jump_url);
	}
	
	/**
	 * 删除落地页
	 * @param t_id
	 * @return
	 */
	@RequestMapping(value = {"del-flooring-page"},method = RequestMethod.POST)
	@ResponseBody
	MessageUtil delFlooringPage(int t_id) {
		
		return  channelService.delFlooringPage(t_id);
	}
	
	/**
	 * 获取代理列表
	 * @param page
	 * @return
	 */
	@RequestMapping(value = {"get-channel-list"},method = RequestMethod.POST)
	@ResponseBody
	Map<String, Object> getChannelList(int page,int t_settlement_method ,int condition_id,String condition_name){
		
		return channelService.getChannelList( page, t_settlement_method , condition_id, condition_name);
	}
	
	/**
	 * 启用或者停用渠道代理
	 * @param t_id
	 * @param start_using
	 * @return
	 */
	@RequestMapping(value = {"start-or-stop-channel"},method = RequestMethod.POST)
	@ResponseBody
	MessageUtil startOrStopChannel(int t_id,int start_using) {
		
		return channelService.startOrStopChannel(t_id, start_using);
	}
	
	
	/**
	 * 获取明细
	 * @param t_id
	 * @return
	 */
	@RequestMapping(value = {"get-channel-detail"},method = RequestMethod.POST)
	@ResponseBody
	Map<String, Object> getChannelDetail(int t_id) {
		
		return channelService.getChannelDetail(t_id);
	}
	
	/**
	 * 更新信息
	 * @param t_id
	 * @param t_real_name
	 * @param t_gold_commission
	 * @param t_vip_commission
	 * @param t_settlement_type
	 * @param t_bank_number
	 * @param t_bank_of_deposit
	 * @param t_account_name
	 * @return
	 */
	@RequestMapping(value = {"update-channel"},method = RequestMethod.POST)
	@ResponseBody
	MessageUtil updateChannel(int t_id,String t_real_name,String t_channel_name,Double t_gold_commission,
			Double t_vip_commission,int t_settlement_type,String t_bank_number,
			String t_bank_of_deposit,String t_account_name,
			String login_name,String login_pass,
			String t_settlement_method,String t_settlement_percent,String t_remarks,int t_channel_price) {
		
		return channelService.updateChannel(t_id, t_real_name, t_channel_name, t_gold_commission, t_vip_commission, 
				t_settlement_type, t_bank_number, t_bank_of_deposit, t_account_name,
				 login_name, login_pass,
				 t_settlement_method, t_settlement_percent, t_remarks, t_channel_price);
	}
	
	/**
	 * 获取渠道数据
	 * @param page
	 * @return
	 */
	@RequestMapping(value = {"get-channel-data-list"},method = RequestMethod.POST)
	@ResponseBody
	Map<String, Object> getChannelDataList(int page,int t_settlement_method ,String beginTime,String endTime,int condition_id,String condition_name){
		return channelService.getChannelDataList(page,t_settlement_method , beginTime, endTime,condition_id,condition_name);
	}
	
	/**
	 *  设置结算转化率
	 * @param page
	 * @return
	 */
	@RequestMapping(value = {"settle-to_percent-data"},method = RequestMethod.POST)
	@ResponseBody
	MessageUtil setChannelPercent(int t_id,int t_settlement_percent){
		
		return channelService.setChannelPercent(t_id,t_settlement_percent);
	}
	/**
	 *  	发布渠道日结算数据
	 * @param t_id
	 * @return
	 */
	@RequestMapping(value = {"settle-to_release-data"},method = RequestMethod.POST)
	@ResponseBody
	MessageUtil setChannelrelease(int t_id,int t_is_release){
		
		return channelService.setChannelrelease(t_id,t_is_release);
	}
	
	
	/**
	 * 结算订单
	 * @param t_id
	 * @return
	 */
	@RequestMapping(value = {"settle-account-channel-data"},method = RequestMethod.POST)
	@ResponseBody
	MessageUtil settleAccountChannelData(int t_id) {
		
		return channelService.settleAccountChannelData(t_id);
	}
	
	
	/**
	 * 获取二级列表
	 * @param page
	 * @return
	 */
	@RequestMapping(value = {"get-two-channel-list"},method = RequestMethod.POST)
	@ResponseBody
	Map<String, Object> getTwoChannelList(int page,int t_settlement_method ,int condition_id,String condition_name){
		
		return channelService.getTwoChannelList(page, t_settlement_method , condition_id,condition_name);
	}
	
	/**
	 * 获取列表
	 * @param page
	 * @return
	 */
	@RequestMapping(value = {"get-channel-material"},method = RequestMethod.POST)
	@ResponseBody
	Map<String, Object> getChannelMaterial(int page){
	
		return channelService.getChannelMaterial(page);
	}
	
	/**
	 * 删除渠道素材
	 * @param t_id
	 * @return
	 */
	@RequestMapping(value = {"del-channel-material"},method = RequestMethod.POST)
	@ResponseBody
	MessageUtil delChannelMaterial(int t_id) {
		
		return channelService.delChannelMaterial(t_id);
	}
	
	
	@RequestMapping(value = {"save-or-update-channel-material"},method = RequestMethod.POST)
	@ResponseBody
	MessageUtil saveOrUpdateChannelMaterial(Integer t_id,String t_img,String t_size) {
		
		return channelService.saveOrUpdateChannelMaterial(t_id, t_img, t_size);
	}
	@RequestMapping(value = {"getChannelDowList"},method = RequestMethod.POST)
	@ResponseBody
	Map<String, Object> getChannelDowList(Integer page,String pageSize) {
		
		return channelService.getChannelDowList(page,pageSize);
	}
	
	
	@RequestMapping(value = {"delChannelPacById"},method = RequestMethod.POST)
	@ResponseBody
	MessageUtil delChannelPacById(Integer t_id) {
		
		return channelService.delChannelPacById(t_id);
	}
	
	@RequestMapping(value = {"addChannelPac"},method = RequestMethod.POST)
	@ResponseBody
	MessageUtil addChannelPac(String t_pac_name,String t_pac_version ) {
		
		return channelService.addChannelPac(t_pac_name,t_pac_version);
	}
	
}
